import requests
import logging as log
import json


def get_mysql_all_slave(orchestrator_username, orchestrator_password, orchestrator_url, mysql_host, mysql_port):
    url = "{orchestrator_url}/api/instance/{mysql_host}/{mysql_port}".format(orchestrator_url=orchestrator_url,
                                                                             mysql_host=mysql_host,
                                                                             mysql_port=mysql_port)

    orchestrator_instance_info_types = requests.get(url, auth=(orchestrator_username, orchestrator_password)).content
    orchestrator_instance_info_str = str(orchestrator_instance_info_types, encoding="utf-8")
    orchestrator_instance_info = json.loads(orchestrator_instance_info_str)
    if isinstance(orchestrator_instance_info, dict):
        slave_list = orchestrator_instance_info.get('SlaveHosts')
        return slave_list
    return
